package org.wheel.plugins.toolkit.util.sql.ai;


import lombok.Data;
import org.wheel.plugins.toolkit.sql.core.LambdaDeleteWrapper;
import org.wheel.plugins.toolkit.sql.core.LambdaQueryWrapper;
import org.wheel.plugins.toolkit.sql.enums.Dialect;
import org.wheel.plugins.toolkit.sql.enums.SqlModel;

/**
 * 直接跑 main，看各种 DELETE SQL 输出
 */
public class DeleteSampleMain {

    @Data
    static class User {
        public Long id;
        public String name;
        public Integer age;
    }
    @Data
    static class Order {
        public Long id;
        public Long userId;
    }

    public static void main(String[] args) {
        /* 1. 基本删除 */
        LambdaDeleteWrapper<User> w1 = new LambdaDeleteWrapper<>(User.class)
                .eq(User::getName, "Tom");
        print(w1, "---- 基本等值 ----");

        /* 2. 子查询 */
        LambdaDeleteWrapper<User> w2 = new LambdaDeleteWrapper<>(User.class)
                .inSub(User::getId,
                        new LambdaQueryWrapper<>(Order.class)
                                .select(Order::getUserId)
                                .eq(Order::getId, 1));
        print(w2, "---- IN 子查询 ----");

        /* 3. 切换方言 & 占位符风格 */
        LambdaDeleteWrapper<User> w3 = new LambdaDeleteWrapper<>(User.class)
                .eq(User::getAge, 18)
                .dialect(Dialect.MYSQL)
                .sqlModel(SqlModel.MYBATIS);
        print(w3, "---- Mybatis 风格 ----");
    }

    private static void print(LambdaDeleteWrapper<?> w, String title) {
        System.out.println(title);
        System.out.println("SQL : " + w.getSql());
        System.out.println("Params: " + w.getParamMap());
        System.out.println();
    }
}